﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAO;
using DTO;
using System.Data;
using System.Data.SqlClient;

namespace BUS
{
    public class BUSNguoiDung
    {
        public static DataTable DanhSachTaiKhoan()
        {
            return DAONguoiDung.DanhSachTaiKhoan();
        }

        public static DataTable TimKiemTaiKhoan(DTONguoiDung nguoidung)
        {
            try
            {
                DataTable kq =  DAONguoiDung.TimKiemTaiKhoan(nguoidung);
                return kq;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static int ThemTaiKhoan(DTONguoiDung nguoidung)
        {
            try
            {
                if (nguoidung.UserName.Length >= 7)
                {
                    return DAONguoiDung.ThemTaiKhoan(nguoidung);
                }
                else
                {
                    int kq = -2;
                    return kq;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static int CapNhatTaiKhoan(DTONguoiDung nguoidung)
        {
            try
            {
                return DAONguoiDung.CapNhatTaiKhoan(nguoidung);
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }

        public static int XoaTaiKhoan(DTONguoiDung nguoidung)
        {
            try
            {
                return DAONguoiDung.XoaTaiKhoan(nguoidung);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static int CapNhatMatKhau(DTONguoiDung nguoidung)
        {
            try
            {
                int kq = 0;
                return kq = DAONguoiDung.CapNhatMatKhau(nguoidung);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
